﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AncientLand.Service.Entity;
using AncientLand.Service.IBiz;
using AncientLand.Service.IDa;

namespace AncientLand.Biz
{
    public class PackagesBiz:IPackagesBiz
    {
        private readonly IPackagesRepository _packagesRepository;
        private readonly ICommit _commitAble;
        public PackagesBiz(IPackagesRepository packagesRepository, ICommit commitAable)
        {
            this._packagesRepository = packagesRepository;
            this._commitAble = commitAable;
        }  

        public IEnumerable<Packages> GetAll()
        {
          return  _packagesRepository.GetAll();
        }

        public Packages GetById(int id)
        {
            return _packagesRepository.GetById(id);
        }

        public void Create(Packages news)
        {
            _packagesRepository.Add(news);
            Save();
        }

        public void Delete(int id)
        {
            var packages = _packagesRepository.GetById(id);
            _packagesRepository.Delete(packages);
            Save();
        }

        public void Save()
        {
            _commitAble.Commit();
        }
    }
}
